<html>
<head>
 <title>Messengers</title>
</head>

<body>
<center>
<h1>POI III Stage I Problem 3</h1>
<h1>Messengers</h1>
</center>
<p>King Informaticus, a ruler of Byteland has a lot to worry about. Secret service informed
him that a cruel King Hacker is about to attack his kingdom. Moreover, secret agents
of Hacker have been already sent to one of the cities in
Byteland in order to hinder preparations for defense. Informaticus decided to warn his subjects against an oncoming danger.&nbsp;<br>
<br>
Citizens of Byteland live only in cities. Cities have numbers from 1 to <i>n</i>, where 3 &lt;=
<i> n</i> &lt;= 500. The capital city has
number 1. There is a well developed system of roads in Byteland, all of them are
two-way roads. Any two cities have no more than one
direct connection, but for any two different cities <i> A</i> and <i> B</i> one can get from
<i> A</i> to <i> B</i> and then return from <i> B</i> to <i> A</i> without going
again through any of the cities on the way from <i> A</i> to <i>B</i>.&nbsp;<br>
<br>
King Informaticus decided to send two messengers to warn his subjects. Each
messenger moves on the roads of Byteland and may visit one city a couple of times. But the order in which they arrive to certain cities
for the first time should be in accord with King's plan.&nbsp;<br>
<br>
The plan is a series of <i> n</i> integers <i> x<sub>1</sub></i>, <i> x<sub>2</sub></i>, ...,
<i> x</i><sub><i>n</i></sub> from the interval [1..<i>n</i>], where <i>
x<sub>1</sub> </i> = 1. On the way from the city <i> x</i><sub><i>i</i></sub> to the city
<i> x<sub>i+1</sub>  </i>  an agent can go through any finite number of cities, but only these that he had visited before. Unfortunately,
spies of King Hacker sat a trap to catch the messengers and imprison any of them who comes to the
occupied city. Thus the plan of routes of two messengers should be such that each
city is visited by at leas one messenger, before they will be captured by agents
hidden in one of the cities different than the capital.&nbsp;</p>
<h2>Task</h2>
<p>Write a program that:</p>
<ul type="disc">
  <li>reads from the text file GON.IN an integer <i> n</i> - the number of all the cities in
    Byteland, an integer <i> d</i> - the number of all the roads directly connecting two different cities as well as descriptions of all direct road connections,</li>
  <li>prepares plans of the routes of two messengers beginning in the capital city
    and then proceeding in such a way that
    each city in Byteland is visited by at least one messenger before spies of Hacker
    capture them,</li>
  <li>writes these plans in the text file GON.OUT.&nbsp;<br>
  </li>
</ul>
<h2>Input</h2>
In the first line of the text file GON.IN one integer <i> n</i> is written. This is the number of all the cities in
Byteland. In the second line one integer <i> d</i> is written. This is the number of all the direct road connections. In each of the following
<i> d</i> lines  there is
written the description of one direct road connection, it consists of two different integers from the interval
[1..<i>n</i>]
separated by a single space. Each connection appears only once in the text file.&nbsp;
<p>&nbsp;
<h2>Output</h2>
In the first line of the text file GON.OUT there should be written the plan of the route of the
first messenger as a series of <i> n</i> different integers from the interval
[1..<i>n</i>],
separated by a single space. In the second line there should be written, in the same way,
the plan of the route of the second agent. 
<p>&nbsp;
<h2>Example</h2>
<center><img src="image/118.gif"></center><br>
The file GON.IN is the description of the road system shown on the picture:<br>
5<br>
6<br>
1 2<br>
2 3<br>
3 4<br>
4 1<br>
4 5<br>
5 2
<p>
In this case the correct solution is the file GON.OUT:<br>
1 2 3 5 4<br>
1 4 5 3 2</p>
<p>
The first messenger could move on the route : 1 2 3 2 5 4, and the second one on the
route : 1 4 5 4 3 2.</p>
</body>

</html>
